package pms.contract;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import pms.contract.ContractManager;
import pms.contract.UserManager;
import pms.contract.domain.User;
import pms.contract.service.GenericGenerator;

public class UserEntityGenerator extends GenericGenerator{

	@Autowired
	UserManager userManager;
	
	@Autowired
	ContractManager contractManager;
	
	@Test
	public void gen_user() {
		for (int i = 0; i < 10; i++) {
			User user=new User();
			user.setUsername("user_"+i);;
			this.userManager.save(user);
			for (int j = 0; j < 10; j++) {
				User u=new User();
				u.setUsername("user_"+i+"_"+j);
				user=this.userManager.save(u);
				this.gen_contract(user);
			}
		}
	}
	
	public void gen_contract(User user) {
		for (int i = 0; i < 10; i++) {
			User u=new User();
			u.setUsername("username_"+i);
			u.setPassword("password_"+i);
			u.setLast_ip("last_ip_"+i);
			this.userManager.save(u);
		}
	}
}
